package com.hzdp.service.impl;

import java.sql.SQLException;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hzdp.dao.PatientDao;
import com.hzdp.entity.Patient;
import com.hzdp.service.PatientService;

@Service
public class PatientServiceImpl implements PatientService {

	@Autowired
	private PatientDao patientDao;

	protected Logger logger = Logger.getLogger(getClass());

	@Override
	public List<Patient> findAll() {
		List<Patient> patients = null;
		try {
			patients = patientDao.findAll();
		} catch (SQLException e) {
			logger.error(e, e);
		}
		return patients;
	}

	@Override
	public Patient findById(int id) {
		Patient patient = null;
		try {
			patient = patientDao.find(id);
		} catch (SQLException e) {
			logger.error(e, e);
		}
		return patient;
	}

	@Override
	public void save(Patient patient) {
		try {
			patientDao.save(patient);
		} catch (SQLException e) {
			logger.error(e, e);
		}
	}

}
